<?php
/* Home controller 
** thaodx@gmail.com
*/
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Detail extends CI_Controller {
	// Layout used in this controller
    public $layout_view = 'layout/tattoos';
	public function index($id = 0)
	{
		 $id = intval($id);		 
		 $data = array();
		 if($id > 0){
		 	$this->load->model('Post_model', 'postModel');
		 	$this->load->helper(array('datetime', 'permalink', 'social', 'image'));
		 	$postDetail = $this->postModel->getPostDetail($id);
		 	$this->layout->title(strip_tags($postDetail[0]->post_title)); // Set page title
		 	$this->layout->desc(strip_tags($postDetail[0]->post_title)); // Set meta description
		 	$data['permalink'] = permalink(array('text' => $postDetail[0]->post_title, 'id' => $postDetail[0]->id));
		 	// meta tags
		 	
		 	$this->layout->meta('<meta property="og:image" content="'.getThumbnail('460x460', $postDetail[0]->post_image).'"/>');
		 	$this->layout->meta('<meta property="og:title" content="'.str_replace('"', '', $postDetail[0]->post_title).'"/>');
		 	$this->layout->meta('<meta property="og:url" content="'.$data['permalink'].'"/>');
		 	$data['detail'] = $postDetail[0];		 	
		 }
		if(!empty($data['detail'])){		 	
		 		$data['olderPost'] = $this->postModel->getOlderPost($data['detail']->id,5);		 			 		
		}		
		// 	$this->postModel->updatePostView($id);
			$this->layout->view('detail_index', $data);		
	}
}